<template>
  <div class="bg">
    <div class="login_box">
      <div class="left">
        <div class="img_box">
          <img src="../assets/img/undraw_forgot_password_re_hxwm 1.png" alt="">
        </div>
      </div>
      <div class="right">
        <p>重置密码</p>
        <el-form :model="loginForm"
         :rules="loginRules"
          ref="loginFormRef"
          label-position="top"
          class="login_form"
          >
          <el-form-item label="邮箱" prop="email" class="item">
            <el-input v-model.trim="loginForm.email"></el-input>
          </el-form-item>
          <el-form-item class="btns">
            <el-button type="primary" @click="reset">发送</el-button>
          </el-form-item>
        </el-form>
        <div class="bottom-left">
          <span>你已有账号?</span>
          <el-button type="text" @click="login"><span>用户登录</span></el-button>
        </div>
        <div class="bottom-right">
          <span>建立新账号?</span>
          <el-button type="text" @click="reguser"><span>用户注册</span></el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    // 邮箱验证规则
    var checkEmail = (rules, value, cb) => {
      const regEmail = /^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$/
      if (regEmail.test(value)) {
        return cb()
      } else {
        return cb(new Error('请输入合法的邮箱'))
      }
    }
    return {
      loginForm: {
        email: ''
      },
      checked: false,
      loginRules: {
        email: [
          { required: true, message: '请输入邮箱', trigger: 'blur' },
          { validator: checkEmail, trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    reguser () {
      this.$router.push({ path: '/reguser' })
    },
    login () {
      this.$router.push({ path: '/login' })
    },
    reset () {
      this.$refs.loginFormRef.validate(async valid => {
        // eslint-disable-next-line no-useless-return
        if (!valid) return
        this.$router.push({ path: '/reset' })
      })
    }
  }
}
</script>

<style lang="less" scoped>
  .bg {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f7f7f7;
    overflow-y: hidden;
  }

  .login_box {
    width: 1440px;
    height: 1024px;
    background-color: #fff;
    display: flex;
  }
  .left {
    width: 720px;
    height: 1024px;
    background-color: #9A9AEB;
    position: relative;
    .img_box {
      width: 567px;
      height: 339px;
      position: absolute;
      top:293px;
      left: 99px;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  .right {
    width: 720px;
    height: 1024px;
    position: relative;
    p {
      position: absolute;
      width: 129px;
      height: 38px;
      top: 297px;
      right: 305px;
      margin-bottom: 0px;
      color: rgb(0, 0, 0);
      font-family: Roboto;
      font-size: 32px;
      font-weight: 500;
      line-height: 38px;
      letter-spacing: 0%;
      text-align: left;
    }
  }
  .login_form {
    position: absolute;
    top: 378px;
    left: 147px;
    width: 446px;
    margin-top: 39px;
    .item ::v-deep .el-form-item__label {
      padding-top: 15px;
      color: rgb(0, 0, 0);
      font-family: Roboto;
      font-size: 24px;
      font-weight: 400;
      line-height: 28px;
      letter-spacing: 0%;
      text-align: left;
    }
    // .el-form-item {
    //   margin-bottom: 30px;
    // }
    .el-input ::v-deep .el-input__inner {
      border:1px solid #4D4DDB;
    }
  }

  .btns {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    .btns ::v-deep .el-button--primary {
      width: 446px;
      height: 55px;
    }
    .el-button {
      margin: 0px;
      width: 446px;
      height: 55px;
      background: rgb(30, 30, 30);
      border-radius: 8px;
      color: rgb(255, 255, 255);
      font-family: Roboto;
      font-size: 24px;
      font-weight: 500;
      line-height: 28px;
      letter-spacing: 0%;
      text-align: center;
    }
    .btns ::v-deep .el-button:focus, .el-button:active {
      background: #66b1ff;
      border-color: #66b1ff;
      color: #FFF;
    }
  }
  .bottom-left {
    position: absolute;
    width: 205px;
    height: 23px;
    top: 623px;
    left: 127px;
    text-align: center;
    span {
      font-family: Roboto;
      font-size: 20px;
      font-weight: 400;
      line-height: 23px;
      letter-spacing: 0%;
    }
    .el-button {
      padding: 0;
    }
  }
  .bottom-right {
    position: absolute;
    width: 205px;
    height: 23px;
    top: 623px;
    right: 147px;
    text-align: center;
    span {
      font-family: Roboto;
      font-size: 20px;
      font-weight: 400;
      line-height: 23px;
      letter-spacing: 0%;
    }
    .el-button {
      padding: 0;
    }
  }

//}
</style>
